#include<bits/stdc++.h>
using namespace std;
const int N=2e5+2;
int q[N];
int a[N],n,i,ma,T;
void dfs(int x){
    if(x==n){
        int s=0;
        for(int i=1;i<=n;i++){
            int l=0,r=0;
            if(q[i]==1){
                if(q[i]==q[l])s+=q[i];
                l=i;
            }
            else{
                if(q[i]==q[r])s+=q[i];
                r=i;
            }
        }
        if(s>ma){
            ma=s;
        }
        return;
    }
    else
    for(int i=x+1;i<=n;i++){
       q[i]=1;
       dfs(i);
       q[i]=-1;
       dfs(i);
    }
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    scanf("%d",&T);
    for(int j=1;j<=T;j++){
        ma=0;
        memset(q,0,sizeof(q));
        scanf("%d",&n);
        for(i=1;i<=n;i++){
            scanf("%d",&a[i]);
        }
        dfs(0);
        printf("%d\n",ma);
    }
    return 0;
}
